#ifndef _COMPLEX_
#define _COMPLEX_

#include <ostream>

using namespace std;

namespace moremath{
class complex{
protected:
	double mReal;
	double mImag;

public:
	complex(double _r, double _i){
		mReal = _r;
		mImag = _i;
	}
	complex(double _r){
		mReal = _r;
		mImag = 0;
	}
	complex(){mReal=0.0; mImag=0.0;}

	//double& operator[] (int i);	// indexing operator
	inline double& re(){return mReal;}
	inline double& im(){return mImag;}
	void operator = (complex);	// assign one to other
	complex operator + (complex);
	void operator += (complex);
	complex operator - ();
	complex operator - (complex);
	complex operator * (complex);
	complex operator * (double);	// multiplies with a scalar
	void operator *= (double);	// multiplies with a scalar
	void operator *= (complex);	// multiplies with a complex number
	complex operator / (double);	// divides by a number
	complex inv();
	complex operator / (complex);	// divides by a complex num

	double norm();	// returns the norm
	complex conj();	// returns the complex conjugate
};

}

std::ostream& operator <<(std::ostream &out, moremath::complex &_c);
moremath::complex exp(moremath::complex q);
moremath::complex sqrt(moremath::complex q);

#endif
